﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Triangle
{
    class Program
    {
        const int row = 10;
        static void Main(string[] args)
        {
            Right(row);
            Isosceles(row);
            Hollow(row);
            Rhombus(row);
            HollowRhombus(row);
            Console.ReadKey();
        }
        //直角三角形
        static void Right(int n)
        {
            for (int i = 1; i <= n; i++)
            {
                Console.Write(new string('*', i));                  //逐行输出对应数量的*；
                Console.WriteLine();
            }
        }
        //等腰三角形
        static void Isosceles(int n)
        {
            for (int i = 1; i <= n; i++)
            {
                Console.Write(new string(' ', n - i));              //输出每一行所需的空格
                Console.Write(new string('*', 2 * i - 1));          //输出对应数量的*
                Console.WriteLine();
            }
        }
        //镂空三角形
        static void Hollow(int n)
        {
            for (int i = 1; i < n; i++)
            {
                Console.Write(new string(' ', n - i));              //输出三角形前的空格
                Console.Write("*");                                 //输出每行左边的*
                if (i >= 2)
                {
                    Console.Write(new string(' ', 2 * i - 3));      //输出三角形内的空格

                    Console.Write("*");                             //输出每行右边的*
                }

                Console.WriteLine();
            }

            Console.Write(new string('*', 2 * n - 1));              //输出最后一行
            Console.WriteLine();
        }
        //菱形
        static void Rhombus(int n)
        {
            for (int i = 1; i <= n; i++)
            {
                Console.Write(new string(' ', n - i));              //输出每一行所需的空格

                Console.Write(new string('*', 2 * i - 1));          //输出对应数量的*
                Console.WriteLine();
            }
            for (int i = n + 1; i <= 2 * n - 1; i++)
            {

                Console.Write(new string(' ', i - n));              //输出每一行所需的空格

                Console.Write(new string('*', 4 * n - 2 * i - 1));  //输出对应数量的*

                Console.WriteLine();
            }
        }
        //镂空菱形
        static void HollowRhombus(int n)
        {
            for (int i = 1; i <= n; i++)
            {
                Console.Write(new string(' ', n - i));              //输出菱形前的空格

                Console.Write("*");                                 //输出每行左边的*
                if (i >= 2)
                {
                    Console.Write(new string(' ', 2 * i - 3));      //输出菱形内的空格

                    Console.Write("*");                             //输出每行右边的*
                }

                Console.WriteLine();
            }
            for (int i = n + 1; i < 2 * n; i++)
            {
                Console.Write(new string(' ', i - n));              //输出菱形前空格
                Console.Write("*");                                 //输出每行左边的*
                if (i < 2 * n - 1)
                {
                    Console.Write(new string(' ', 4 * n - 2 * i - 3));//输出菱形内空格

                    Console.Write("*");                             //输出菱形右端的*
                }
                Console.WriteLine();
            }
        }
    }
}
